package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCDemo5 {
    public static void main(String[] args) {
        try {
            Connection connection=DBUtil.getConnection();
            Statement statement=connection.createStatement();
            String sql="select id,name,salary,title "+"from teacher";
            ResultSet resultSet=statement.executeQuery(sql);
            while(resultSet.next()){
                int id=resultSet.getInt("id");
                String name=resultSet.getString("name");
                int salary=resultSet.getInt("salary");
                System.out.println(id+" "+name+" "+salary);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
